class Solution(object):
    def findUnsortedSubarray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """

        a = sorted(nums)
        l = -1
        end=-2
        for i in range(len(nums)):
            if a[i] != nums[i]:
                if l==-1:
                    l=i
                end+=1
        return end-l+1